from Base.DataBase import mysqldb


class DataCollect():
    def __init__(self):
        self.execute_sum = 0
        self.success_num = 0
        self.fail_sum = 0
        self.percent = ''
        self.test_start_time  = ''
        self.test_end_time = ''
        self.test_duration_time = ''
        self.Batch_number = ''
        self.case_detail_list = []

    def getdata_from_db(self):
        result_list = mysqldb().read_data()
        self.execute_sum = result_list[0].get('total_excount')
        self.success_num = result_list[0].get('success_cases')
        self.fail_sum = result_list[0].get('failed_cases')
        self.percent = result_list[0].get('percent')
        self.test_start_time = result_list[0].get('start_time')
        self.test_end_time = result_list[0].get('end_time')
        self.test_duration_time =result_list[0].get('count_time')
        for result in result_list:
            detail_info_dict = {}
            detail_info_dict['caseid'] = result.get('case_id')
            detail_info_dict['desc'] = result.get('case_desc')
            detail_info_dict['module'] = result.get('case_module')
            detail_info_dict['res'] = result.get('actual_res')
            detail_info_dict['case_start_time'] =result.get('case_start_time')
            detail_info_dict['case_end_time'] = result.get('case_end_time')
            detail_info_dict['run_time'] = result.get('case_count_time')
            detail_info_dict['res_info'] =result.get('failed_info')
            detail_info_dict['opetator'] = result.get('opetator')
            detail_info_dict['batch_info'] = result.get('batch_info')
            self.case_detail_list.append(detail_info_dict)

